<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('选择课程调换')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <input type="hidden" name="arrangeId" id="arrangeId" th:value="${arrangeId}"/>
                <form id="formId">
                    <input type="hidden" name="teacherId" id="teacherId" th:value="${teacherId}"/>
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>时间段：</p>
                                <select name="timeSlot" th:with="type=${@dict.getType('course_time_slot')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var timeSlotDatas = [[${@dict.getType('course_time_slot')}]];
        var prefix = ctx + "mgr/adjust";

        $(function() {
            var options = {
                url: prefix + "/courseList",
                modalName: "课程安排",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                clickToSelect: true,
                rememberSelected: true,
                columns: [{
                    field: 'state',
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : '排课id',
                    visible: false
                },
                {
                    field : 'clazzId', 
                    title : '班级id',
                    visible: false
                },
                {
                    field : 'roomId', 
                    title : '教室id',
                    visible: false
                },
                    {
                        field : 'roomCode',
                        title : '教室'
                    },
                {
                    field : 'courseId', 
                    title : '课程id',
                    visible: false
                },
                    {
                        field : 'courseName',
                        title : '课程'
                    },
                {
                    field : 'teacherId', 
                    title : '教师id',
                    visible: false
                },
                    {
                        field : 'teacherName',
                        title : '教师'
                    },
                {
                    field : 'courseDate', 
                    title : '课程日期'
                },
                {
                    field : 'timeSlot', 
                    title : '时间段',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(timeSlotDatas, value);
                    }
                }]
            };
            $.table.init(options);
        });
        /* 添加用户-选择用户-提交 */
        function submitHandler() {
            var rows = $.table.selectFirstColumns();
            if (rows.length != 1) {
                $.modal.alertWarning("请选择一条记录");
                return;
            }
            var data = {"arrangeId": $('#arrangeId').val(), "afterArrangeId": rows.join() };
            $.operate.save(ctx + "mgr/adjust/add", data);
        }
    </script>
</body>
</html>